function setpath(basepath)
% setpath  -  search basepath for the files in the control worksheet

%
global CONTROL
if(exist(basepath) ~= 7)
    basepath
    QueMessage(sprintf('setpath: path \"%s\" does not exist', basepath), 1);
    return;
end;


num_found = 0;
num_missing = 0;
knownfile = {};
knownpath = {};
knowinpath = {};
tfiles = 0;
hc = findobj('tag', 'CTL'); % get the selected entries only
ctllist = get(hc, 'value');
for i = ctllist
    k = strmatch(CONTROL(i).filename, knownfile, 'exact'); % check if it is known first
    if(isempty(k))
        newp = update_paths_general(basepath, CONTROL(i).filename);
        tfiles = tfiles + 1;
        knownpath{tfiles} = newp;
        knownfile{tfiles} = CONTROL(i).filename;
        if(isempty(newp))
            fprintf(2, '**** Not found: %s   ****\n', CONTROL(i).filename);
            CONTROL(i).fileinpath = 0;
            knowninpath{tfiles} = 0;
            num_missing = num_missing + 1;
        else
            fprintf(2, 'Found %s  in  %s\n', CONTROL(i).filename, newp);
            num_found = num_found + 1;
            CONTROL(i).path = newp; % and update the path
            CONTROL(i).fileinpath = 1;
            knowninpath{tfiles} = 1;
        end;
    else
        num_found = num_found + 1;
        CONTROL(i).path = knownpath{k};
        CONTROL(i).fileinpath = knowninpath{k};
    end;

end;
fprintf(2, '\nTotal Found: %d     Total Missing = %d\n', num_found, num_missing);

return;

